﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Velocity
{
    class Program
    {
        static void Main(string[] args)
        {
            console.BlankLine();
            console.CenterLine("---------  Velocity Compiler  ---------");
            foreach (string Cmd in args)
            {
                if (Cmd.EndsWith(".velo"))
                {
                    console.SuccessLine("Located Velocity file: " + Cmd);
                    CompileFile(Cmd);
                    break;
                }
                else
                {
                    console.WarnLine("Invalid command line specified: " + Cmd);
                }
            }
            console.PauseNoMessage();
        }

        private static void CompileFile(string File)
        {
            CodeProvider codeProvider = new CodeProvider(System.IO.File.ReadAllText(File));
            codeProvider.OnErrorOccured += codeProvider_OnErrorOccured;
            codeProvider.Provide();
            console.CenterLine("--------");
            console.SuccessLine("Code provider has exited.");
        }

        static void codeProvider_OnErrorOccured(string Message, int Line)
        {
            console.WarnLine("Error on line: " + Line + "  " + Message);
        }
    }
}
